<#include "header.htm"/>
<script type="text/javascript">
function checkemail(str) {
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str)) return true;
    else return false;
}

function validateRegistrationForm(f){
	var error = '';
	var result = true;
	if (f.username.value == "") {
		error += '${I18n.getMessage("User.fillUsername")}';
	}
	
	if (f.email.value == "" || checkemail(f.email.value) != true) {
        error += "<br />${I18n.getMessage("User.fillEmail")}";
    }
	
	if (f.password.value == "") {
		error += "<br />${I18n.getMessage("User.fillPassword")}";
	}
	
	if (f.password_confirm.value == "") {
		error += "<br />${I18n.getMessage("User.fillPasswordConfirmation")}";
	}
	
	if (f.password.value != f.password_confirm.value) {
		error += "<br />${I18n.getMessage("User.passwordNotMatch")}";
	}
	if (error != ''){
	    result = false;
	    document.getElementById('error').innerHTML = error;
	} else {
	    document.getElementById('error').innerHTML = '';
	}
	
	return result;
}

function newCaptcha()
{
	document.getElementById("captcha_img").src = "${contextPath}/jforum${extension}?module=captcha&action=regenerate&timestamp=" + new Date().getTime();
}

function formReset(){
    document.getElementById('error').innerHTML = '';
}

</script>

<form id="register" accept-charset="${encoding}" action="${JForumContext.encodeURL("/jforum")}" method="post" onsubmit="return validateRegistrationForm(this);">
<input type="hidden" name="action" value="${action}" />
<input type="hidden" name="module" value="${moduleName}" />

<div class="panel">
	<div class="inner"><span class="corners-top"><span></span></span>
	<#if error?exists>
	    <dl><dd class="error" id='error2'>${error}</dd></dl>
	</#if>

	<h2>${I18n.getMessage("User.registerInformation")}</h2>

	<fieldset class="fields2">
	
	<dl><dd class="error" id='error'></dd></dl>
	
	<dl>
		<dt><label for="username">${I18n.getMessage("User.username")}:</label></dt>
		<dd><input type="text" tabindex="1" name="username" id="username" size="25" value="${username?default("")?html}" class="inputbox autowidth" title="Username" /></dd>
	</dl>
	<dl>
		<dt><label for="email">${I18n.getMessage("User.emailAddress")}:</label></dt>
		<dd><input type="text" tabindex="2" name="email" id="email" size="25" maxlength="100" value="${email?default("")?html}" class="inputbox autowidth" title="E-mail address" /></dd>
	</dl>
	<dl>
		<dt><label for="new_password">${I18n.getMessage("User.password")}:</label></dt>
		<dd><input type="password" tabindex="4" name="password" id="password" size="25" value="" maxlength="100" class="inputbox autowidth" title="New password" /></dd>
	</dl>
	<dl>
		<dt><label for="password_confirm">${I18n.getMessage("User.confirmPassword")}:</label></dt>
		<dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" maxlength="100" value="" class="inputbox autowidth" title="Confirm password" /></dd>
	</dl>

	<hr />

	</fieldset>
	<span class="corners-bottom"><span></span></span></div>
</div>

<#if captcha_reg?exists>
<#include "captche.htm"/>
</#if>	
	
<div class="panel">
	<div class="inner"><span class="corners-top"><span></span></span>

	<fieldset class="submit-buttons">
		<input type="reset" onclick="formReset()" value="${I18n.getMessage("User.reset")}" name="reset" class="button2" />&nbsp;
		<input type="submit" tabindex="9" name="submit" id="submit" value="${I18n.getMessage("User.submit")}" class="button1 default-submit-action" />
		
	</fieldset>

	<span class="corners-bottom"><span></span></span></div>
</div>

</form>







<#include "bottom.htm"/>
